<template>
    <div>
    <Modal :title="modalTitle" v-model="modalVisible" :mask-closable='false' :width="650" :styles="{top: '100px'}">
        <Form ref="form" :model="form" :label-width="80" >
            <FormItem label="赠送学习币" prop="score">
                <InputNumber v-model="form.score" autocomplete="off"/>
            </FormItem>
        </Form>
        <div slot="footer">
            <Button type="text" @click="cancelUser">取消</Button>
            <Button type="primary" :loading="submitLoading" @click="handelSubmit">提交</Button>
        </div>
    </Modal>
    </div>
</template>

<script>
    import {addIntegral} from "@/api/bus";
    export default {
        name: "integralDrawer",
        components: {

        },
        data() {
            return {
                type:0,
                errorPass: "",
                deptLoading: false,
                modalTitle: "赠送学习币",
                submitLoading: false,
                modalVisible: false,
                form: {
                    ids:"",
                    score: 0,
                }
            }
        },
        methods: {
            init() {

            },
            showDrawer(params) {
                this.modalVisible = true;
                if (params.ids) {
                    this.type = 1;
                    this.modalTitle = "赠送学习币";
                    this.form.ids=params.ids;
                }
            },
            cancelUser() {
                this.modalVisible = false;
            },
            handelSubmit() {
                if(this.form.score <= 0){
                    this.$Message.error("赠送学习币不能小于0");
                    return;
                }
                this.$refs.form.validate(valid => {
                    if (valid) {
                        this.submitLoading = true;
                        // 添加 避免编辑后传入id等数据 记得删除
                        addIntegral(this.form).then(res => {
                            this.submitLoading = false;
                            if (res.status === true) {
                                this.$Message.success("添加成功");
                                this.$parent.getDataList();
                                this.modalVisible = false;
                            }
                        });
                    }
                });
            }
        },
        mounted() {

        }
    }
</script>

<style>

</style>